package com.lxq.LeetCode.moveZeroes;

public class Solution {
    public static void main(String[] args) {

    }

    public static int[] moveZeroes(int[] nums) {
        if (nums.length == 1) {
            return nums;
        }
        int p1 = 0;
        int p2 = 0;

        while (p2 < nums.length) {
            if (nums[p2] != 0) {
                nums[p1++] = nums[p2];
            }
            p2++;
        }
        while (p1 < nums.length) {
            nums[p1++] = 0;
        }

        return nums;
    }
}
